using System;
using System.Collections.Generic;
using System.Text;
using System.ComponentModel;

namespace Zsa.Emulation.Mappers
{
    /// <summary>
    /// The mapper information.
    /// </summary>
    [Serializable()]
    public struct MapperInformation
    {
        #region Fields
        /// <summary>
        /// The mapper name.
        /// </summary>
        private readonly string _MapperName;
        /// <summary>
        /// The mapper description.
        /// </summary>
        private readonly string _MapperDescription;
        /// <summary>
        /// The mapper type.
        /// </summary>
        private readonly MapperTypeNumber _MapperTypeNumber;
        /// <summary>
        /// The mapper type.
        /// </summary>
        private Type _MapperType;
        #endregion Fields

        #region Constructor
        /// <summary>
        /// Initializes a new instance of the <see cref="T:MapperInformation"/> class.
        /// </summary>
        /// <param name="mapperName">Name of the mapper.</param>
        /// <param name="mapperDesc">The mapper desc.</param>
        /// <param name="mapperType">Type of the mapper.</param>
        /// <param name="mapperTypeNumber">The mapper type number.</param>
        internal MapperInformation(string mapperName, string mapperDesc, Type mapperType,
            MapperTypeNumber mapperTypeNumber)
        {
            // Check for null arguments.
            if (mapperName == null)
            {
                throw new ArgumentNullException("mapperName");
            }
            if (mapperDesc == null)
            {
                throw new ArgumentNullException("mapperDesc");
            }
            //if (mapperType == null)
            //{
            //    throw new ArgumentNullException("mapperType");
            //}
            // check the mapper type.
            //if (!Enum.IsDefined(typeof(MapperTypeNumber), mapperTypeNumber))
            //{
            //    throw new System.ComponentModel.InvalidEnumArgumentException(
            //        "mapperTypeNumber",
            //        (int)mapperTypeNumber,
            //        typeof(MapperTypeNumber)
            //    );
            //}

            _MapperName = mapperName;
            _MapperDescription = mapperDesc == null ? string.Empty : mapperDesc;
            _MapperTypeNumber = mapperTypeNumber;
            _MapperType = mapperType;
        }
        #endregion Constructor

        #region Properties
        /// <summary>
        /// Gets the mapper type number.
        /// </summary>
        /// <value>The mapper type number.</value>
        public MapperTypeNumber MapperTypeNumber
        {
            get { return _MapperTypeNumber; }
        }
        /// <summary>
        /// Gets the name of the mapper.
        /// </summary>
        /// <value>The name of the mapper.</value>
        public string MapperName
        {
            get { return _MapperName; }
        }
        /// <summary>
        /// Gets the mapper description.
        /// </summary>
        /// <value>The mapper description.</value>
        public string MapperDescription
        {
            get { return _MapperDescription; }
        }
        /// <summary>
        /// Gets the type of the mapper.
        /// </summary>
        /// <value>The type of the mapper.</value>
        public Type MapperType
        {
            get
            {
                return _MapperType;
            }
        }

        /// <summary>
        /// Gets a value indicating whether this instance is standard mapper.
        /// </summary>
        /// <value>
        /// 	<c>true</c> if this instance is standard mapper; otherwise, <c>false</c>.
        /// </value>
        public bool IsStandardMapper
        {
            get
            {
                return (_MapperTypeNumber & MapperTypeNumber.NonStandardMapperFlag)
                != MapperTypeNumber.NonStandardMapperFlag;
            }
        }

        /// <summary>
        /// Gets a value indicating whether this instance is unsupported.
        /// </summary>
        /// <value>
        /// 	<c>true</c> if this instance is unsupported; otherwise, <c>false</c>.
        /// </value>
        public bool IsUnsupported
        {
            get
            {
                return (_MapperTypeNumber & MapperTypeNumber.Unsupported) == MapperTypeNumber.Unsupported;
            }
        }

        /// <summary>
        /// Gets a value indicating whether this instance is empty.
        /// </summary>
        /// <value><c>true</c> if this instance is empty; otherwise, <c>false</c>.</value>
        public bool IsEmpty
        {
            get {
                return _MapperName == null;
            }
        }
        #endregion Properties

        /// <summary>
        /// Returns the fully qualified type name of this instance.
        /// </summary>
        /// <returns>
        /// A <see cref="T:System.String"></see> containing a fully qualified type name.
        /// </returns>
        public override string ToString()
        {
            return _MapperName;
        }

    }
}
